#include "ProgressBar.h"
char bar[SIZE];
const char*WaitChar="-\\|/";

void ProgressBar(int rate)//rate为已下载内容大小跟全部大小的比率
{
    if(rate<0||rate>100)return;
    int len=strlen(WaitChar);
    printf(COLOR"[%-100s]"COLOREND"[%d%%][%c]\r",bar,rate,WaitChar[rate%len]);
    fflush(stdout);
    usleep(50000);
    bar[rate++]=FILL_CHAR;
    if(rate<100)bar[rate]=RIGHT;
}

void BarInit()
{
    memset(bar,0,sizeof(bar));
}